package com.breaker.kata.algorithm;

public class COde01_BSExist {

    // arr 保证有序
    public static boolean find(int[] arr, int num) {
        if (arr == null || arr.length == 0) {
            return false;
        }
        int l = 0;
        int r = arr.length - 1;
        while (l <= r) {
           int mid = (l + r) /2;
           if (arr[mid] == num) {
               return true;
           }else if (arr[mid] < num) {
               l = mid + 1;
           }else {
               r = mid - 1;
           }
        }
        return false;
    }
}
